package com.game.battleship;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class SinglePlayerMenuActivity extends Activity {

	private static final int OPTION_LOGIN_AND_CONTINUE = 0;
	private static final int OPTION_NEW_PLAYER = 1;
	private static final int OPTION_HIGH_SCORES = 2;
	
	private String[] singlePlayerMenuOptions;
	private ListView singlePlayerMenuOptions_ListView;
	private ArrayAdapter<String> singlePlayerMenuOptions_ArrayAdapter;
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.single_player_menu);
        
        singlePlayerMenuOptions_ListView = (ListView)this.findViewById(R.id.singlePLayerMenuOptions_ListView);
        Resources rsc = this.getResources();
        singlePlayerMenuOptions = rsc.getStringArray(R.array.single_player_menu_options);
        
        singlePlayerMenuOptions_ArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, singlePlayerMenuOptions);
        singlePlayerMenuOptions_ListView.setAdapter(singlePlayerMenuOptions_ArrayAdapter);
        
        singlePlayerMenuOptions_ListView.setOnItemClickListener(new OnItemClickListener() {

			public void onItemClick(AdapterView<?> parent, View voew, int pos, long id) {
				// TODO Auto-generated method stub
				switch (pos) {
				case OPTION_LOGIN_AND_CONTINUE: 
					goToPlayerLoginActivity();
					break;
				case OPTION_NEW_PLAYER:
					goToNewPlayerActivity();
					break;
				case OPTION_HIGH_SCORES:
					goToHighScoresActivity();
					break;
				}
			}
        	
        });
	}

	protected void goToHighScoresActivity() {
		// TODO Auto-generated method stub
		Intent intent = new Intent(SinglePlayerMenuActivity.this, HighScoresActivity.class);
		startActivity(intent);
		
	}

	protected void goToPlayerLoginActivity() {
		// TODO Auto-generated method stub
		Intent intent = new Intent(SinglePlayerMenuActivity.this, PlayerLoginActivity.class);
		startActivity(intent);
	}

	protected void goToNewPlayerActivity() {
		// TODO Auto-generated method stub
		Intent intent = new Intent(SinglePlayerMenuActivity.this, NewPlayerActivity.class);
		startActivity(intent);
	}	
}